<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>后台管理</title>
	<link rel="stylesheet" href="<?php echo base_url('static/layui-v2.3.0/css/layui.css'); ?>">
	<link rel="stylesheet" href="<?php echo base_url('static/admin/base.css'); ?>">
	<script src="<?php echo base_url('static/layui-v2.3.0/layui.js'); ?>"></script>
	<script>
		layui.use(['element', 'jquery', 'layer', 'form', 'upload'], function() {
			var element = layui.element,
				$ = layui.jquery,
				layer = layui.layer,
				form = layui.form,
				upload = layui.upload;

			$("a.del").click(function() {
				var $url = $(this).attr("url");
				layer.confirm("删除后将不能恢复，确定删除？", {
						icon: 0,
						title: "提示",
						btn: ["确定", "取消"]
					}, function(index) {
						layer.close(index);
						location.href = $url;
					}, function(index) {
						layer.close(index);
					}
				);
			});

			//执行实例
			var uploadInst = upload.render({
				url: $('.upload-image').data("url")+ "&mr="+ Math.random(),
				elem: '.upload-image',
				method: 'post',
				field: 'file',
				exts: $('.upload-image').data('exts'),
				done: function(res, index, upload) {
					if ("1" == res.status) {
						$('input[name="image"]').val(res.data.file_name);
					} else {
						layer.msg(res.message, {icon: 5, anim: 6});
					}
				},

			});

			form.on('checkbox(auth)', function(data) {
				var $elem = $(data.elem);
				var $parent = $elem.data("parent");
				if ($parent) {
					if (data.elem.checked) {
						$elem.parents("dd").prev("dt").find("input").prop("checked", data.elem.checked);
					}
				} else {
					$elem.parents("dt").next("dd").find("input").prop("checked", data.elem.checked);
				}
				form.render();
			});
		});
	</script>
	<?php if (! empty($kindeditor)): ?>
	<link rel="stylesheet" href="<?php echo base_url('static/kindeditor/themes/default/default.css'); ?>" />
	<link rel="stylesheet" href="<?php echo base_url('static/kindeditor/plugins/code/prettify.css'); ?>" />
	<script charset="utf-8" src="<?php echo base_url('static/kindeditor/kindeditor-all.js'); ?>"></script>
	<script charset="utf-8" src="<?php echo base_url('static/kindeditor/lang/zh-CN.js'); ?>"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content"]', {
				cssPath : '<?php echo base_url('static/kindeditor/plugins/code/prettify.css'); ?>',
				uploadJson : '<?php echo base_url('static/kindeditor/php/upload_json.php'); ?>',
				fileManagerJson : '<?php echo base_url('static/kindeditor/php/file_manager_json.php'); ?>',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					self.sync();
				}
			});
		});
	</script>
	<?php endif; ?>
</head>

<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo">后台管理</div>
			<!-- 头部区域（可配合layui已有的水平导航） -->
			<ul class="layui-nav layui-layout-left">
				<li class="layui-nav-item"><a href="<?php echo site_url('admin'); ?>">后台首页</a></li>
				<li class="layui-nav-item"><a href="">商品管理</a></li>
				<li class="layui-nav-item"><a href="<?php echo site_url('admin/content/add'); ?>">添加内容</a></li>
				<li class="layui-nav-item">
					<a href="javascript:;">其它系统</a>
					<dl class="layui-nav-child">
					<dd><a href="">邮件管理</a></dd>
					<dd><a href="">消息管理</a></dd>
					<dd><a href="">授权管理</a></dd>
					</dl>
				</li>
			</ul>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item">
					<a href="javascript:;">
					<img src="http://t.cn/RCzsdCq" class="layui-nav-img">
					贤心
					</a>
					<dl class="layui-nav-child">
						<dd><a href="">基本资料</a></dd>
						<dd><a href="">安全设置</a></dd>
					</dl>
				</li>
				<li class="layui-nav-item"><a href="<?php echo site_url('admin/user/logout'); ?>">退了</a></li>
			</ul>
		</div>

		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<?php if (! empty($nav)): ?>
				<ul class="layui-nav layui-nav-tree"  lay-filter="test">
					<?php foreach ($nav as $key => $value): ?>
					<li class="layui-nav-item layui-nav-itemed">
						<a class="" href="javascript:;"><?php echo $value['name']; ?></a>
						<?php if (! empty($nav)): ?>
						<dl class="layui-nav-child">
							<?php foreach ($value['children'] as $k => $v): ?>
							<dd><a href="<?php echo $v['url']; ?>"><?php echo $v['name']; ?></a></dd>
							<?php endforeach; ?>
						</dl>
						<?php endif; ?>
					</li>
					<?php endforeach; ?>
				</ul>
				<?php endif; ?>
			</div>
		</div>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div style="padding: 15px;">
				<?php $this->load->view('admin/'. $this->router->class .'/'. $this->router->method); ?>
			</div>
		</div>

		<div class="layui-footer">
		<!-- 底部固定区域 -->
		© layui.com - 底部固定区域
		</div>
	</div>
</body>
</html>
